package utils;

/**
 *
 */
public class Lock
{
    private boolean locked_ = true;

    /**
     * Constructor.
     *
     * The lock will be locked by default.
     */
    public Lock()
    {
        
    }

    /**
     * Constructor.
     * 
     * @param isLocked true if the lock should be locked from the beginning
     */
    public Lock( boolean isLocked )
    {
        locked_ = isLocked;
    }

    /**
     * Locks the lock.
     */
    public final void lock()
    {
        locked_ = true;
    }

    /**
     * Unlocks the lock.
     */
    public final void unlock()
    {
        locked_ = false;
    }

    /**
     * Checks if the lock is locked.
     *
     * @return true if locked
     */
    public final boolean isLocked()
    {
        return locked_;
    }
}
